View or edit SQL statements in a query
If you know Structured Query Language (SQL), you can use SQL to edit the SQL SELECT
statement for a query.
- Create a new query. Do not return the results to Microsoft Excel.
- Click SQL View.
The Tables pane displays the SQL SELECT statement that corresponds to the query.
- Type any changes you want to make into the SQL statement.
To add a new line, press RETURN.
Notes
- To change or replace the SQL statement, use the same SQL syntax that Microsoft Query uses or the syntax your data source supports. Microsoft Query tries to interpret the syntax you use and displays both the query's design and its result set.
- If Microsoft Query can't display the query's design in
Query view, it's most likely because Query
view can't interpret a portion of the syntax you used. In
these situations, a result set can still be displayed in the Data pane,
but you must make any change to the query definition, such as adding or
removing fields, in SQL view.
Related topics
Create a query
Return a result set to Microsoft Excel